let portrait = document.querySelector(".portrait");
let name = document.querySelector(".name-box p");
let brief = document.querySelector(".brief");
let sex = document.querySelector(".img02");
let values = localStorage.getItem("jwt");

(function () {
    fetch('/user_message/userBrief', {
        method: 'GET',
        headers: {
            'authorization': values
        }
    }).then(response => {
        if (!response.ok) {
            throw new Error('网络请求错误: ' + response.status + ' ' + response.statusText);
        }
        return response.json();
    }).then(data => {
        data[0]['user_icon'] = data[0]['user_icon']['data']
            .map(code => String.fromCharCode(code)).join('');

        sex.src = data[0]['sex'] == "男" ? "/images/my/xingbie_1.png":"/images/my/xingbie.png"
        name.textContent = data[0]['username'] // 用户名
        portrait.src = data[0]['user_icon'] // 头像
        brief.textContent = data[0]['profile'] // 简介 
    })
})();
